package org.example.test.domain;

import lombok.extern.slf4j.Slf4j;
import org.example.domain.strategy.model.entity.StrategyAwardEntity;
import org.example.domain.strategy.model.entity.StrategyEntity;
import org.example.domain.strategy.service.armory.IStrategyArmory;
import org.example.domain.strategy.service.armory.IStrategyDispatch;
import org.example.domain.strategy.service.rule.tree.factory.DefaultTreeFactory;
import org.example.infrastructure.persistent.dao.IStrategyAwardDao;
import org.example.infrastructure.persistent.dao.IStrategyDao;
import org.example.infrastructure.persistent.dao.IStrategyRuleDao;
import org.example.infrastructure.persistent.po.Strategy;
import org.example.infrastructure.persistent.po.StrategyAward;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;

@Slf4j
@SpringBootTest
@RunWith(SpringRunner.class)
public class StrategyArmoryTest {
    @Resource
    private IStrategyArmory strategyArmory;
    @Resource
    private IStrategyDispatch strategyDispatch;
    @Resource
    private IStrategyRuleDao strategyRuleDao;
    @Resource
    private IStrategyAwardDao strategyAwardDao;
    @Resource
    private IStrategyDao strategyDao;
    @Resource
        private DefaultTreeFactory defaultTreeFactory;
    @Test
    public void test_strategyArmor(){
        strategyArmory.assembleLotteryStrategy(1001l);
    }
 @Test
    public void test_strategyArmory(){

        log.info("测试结果,{}",strategyDispatch.getRandomAwardId(1001l));
        log.info("测试结果,{}",strategyDispatch.getRandomAwardId(1001l));
        log.info("测试结果,{}",strategyDispatch.getRandomAwardId(1001l));
    }
    @Test
    public void test_strategyArmory1(){

        log.info("测试结果,{}",strategyDispatch.getRandomAwardId(1001l,"5000:103,104,105,106,107"));
        log.info("测试结果,{}",strategyDispatch.getRandomAwardId(1001l,"4000:102,103,104,105"));
        log.info("测试结果,{}",strategyDispatch.getRandomAwardId(1001l,"6000:104,105,106,107,108"));
    }
@Test
    public void test_strategyAward(){
        StrategyAward strategyAward = strategyAwardDao.queryStrategyAwardByAwardId(104l);
         StrategyAwardEntity strategyAwardEntity = StrategyAwardEntity.builder()
                  .strategyId(strategyAward.getStrategyId())
                  .awardId(strategyAward.getAwardId())
                  .awardCount(strategyAward.getAwardCount())
                  .awardCountSurplus(strategyAward.getAwardCountSurplus())
                  .awardRate(strategyAward.getAwardRate())
                  .build();
        log.info("测试结果,{}",strategyAwardEntity);
    }
@Test
    public void test_strategy(){
        Strategy strategy = strategyDao.queryStrategyBystrategyId(1001l);
         StrategyEntity strategyEntity = StrategyEntity.builder()
                  .strategyId(strategy.getStrategyId())
                  .ruleModels(strategy.getRuleModels())
                  .build();

        log.info("测试结果,{}",strategyEntity);
    }
    @Test
    public void test_tree_rule() {

    }
}
